#include <iostream>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>

using namespace std;

int main()
{
    pid_t id = fork();
    if (id < 0)
    {
        cerr << "fork error" << endl;
    }
    // child
    if (id == 0)
    {
        cout << "sleeping...." << endl;
        sleep(5);
        cout << "over" << endl;
        exit(0);
    }

    while(true)
    {
        cout << "父进程ing" << endl;
        sleep(1);
    }

    waitpid(id,nullptr,0);


    return 0;
}